From: Jeroen van der Heijden Date: Wed, 10 Oct 2018 07:16:58 +0000 (+0200) Subject: assert, switch to NDEBUG X-Git-Tag: archive/raspbian/2.0.44-1+rpi1~1^2~3^2~8^2~21 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5254cdc036831eddaa7595e71e45655f7771ef9e;p=siridb-server.git assert, switch to NDEBUG --- diff --git a/src/cexpr/cexpr.c b/src/cexpr/cexpr.c index 89915f35..61bb6fe5 100644 --- a/src/cexpr/cexpr.c +++ b/src/cexpr/cexpr.c @@ -96,9 +96,7 @@ cexpr_t * cexpr_from_node(cleri_node_t * node) { /* successful */ cexpr = CEXPR_close_curly(&list); -#if DEBUG assert (list.len == 0 && condition == NULL); -#endif } else if (condition != NULL) { @@ -179,10 +177,7 @@ int cexpr_str_cmp( const char * b) { /* both a and b MUST be terminated strings */ - -#if DEBUG assert (a != NULL && b != NULL); -#endif switch (operator) { @@ -218,9 +213,8 @@ int cexpr_bool_cmp( const int64_t a, const int64_t b) { -#if DEBUG assert ((a == 0 || a == 1) && (b == 0 || b == 1)); -#endif + switch (operator) { case CEXPR_EQ: @@ -243,10 +237,8 @@ int cexpr_run(cexpr_t * cexpr, cexpr_cb_t cb, void * obj) switch (cexpr->operator) { case CEXPR_AND: -#if DEBUG /* tp_a cannot be VIA_NULL, but tp_b can */ assert (cexpr->tp_a != VIA_NULL); -#endif return ((cexpr->tp_a == VIA_CEXPR) ? cexpr_run(cexpr->via_a.cexpr, cb, obj) : cb(obj, cexpr->via_a.cond)) && @@ -254,10 +246,8 @@ int cexpr_run(cexpr_t * cexpr, cexpr_cb_t cb, void * obj) cexpr_run(cexpr->via_b.cexpr, cb, obj) : cb(obj, cexpr->via_b.cond))); case CEXPR_OR: -#if DEBUG /* both tp_a and tp_b can NEVER be VIA_NULL */ assert (cexpr->tp_a != VIA_NULL && cexpr->tp_b != VIA_NULL); -#endif return ((cexpr->tp_a == VIA_CEXPR) ? cexpr_run(cexpr->via_a.cexpr, cb, obj) : cb(obj, cexpr->via_a.cond)) || @@ -327,9 +317,7 @@ cexpr_operator_t cexpr_operator_fn(cleri_node_t * node) } else { -#if DEBUG assert (node->len == 2); -#endif switch (*node->str) { case '=': return CEXPR_EQ; @@ -668,9 +656,7 @@ static void CEXPR_push_condition(cexpr_t * cexpr, cexpr_condition_t * cond) } else { -#if DEBUG - assert(cexpr->tp_b == VIA_NULL); -#endif + assert(cexpr->tp_b == VIA_NULL);#endif cexpr->tp_b = VIA_COND; cexpr->via_b.cond = cond; } @@ -704,9 +690,7 @@ static cexpr_t * CEXPR_open_curly(cexpr_t * cexpr, cexpr_list_t * list) } else { -#if DEBUG assert(cexpr->tp_b == VIA_NULL); -#endif cexpr->tp_b = VIA_CEXPR; cexpr->via_b.cexpr = new_cexpr; } @@ -716,9 +700,7 @@ static cexpr_t * CEXPR_open_curly(cexpr_t * cexpr, cexpr_list_t * list) static cexpr_t * CEXPR_close_curly(cexpr_list_t * list) { -#if DEBUG assert (list->len > 0); -#endif list->len--; return list->cexpr[list->len]; } diff --git a/src/ctree/ctree.c b/src/ctree/ctree.c index ba888464..4d84a619 100644 --- a/src/ctree/ctree.c +++ b/src/ctree/ctree.c @@ -630,10 +630,7 @@ static int CT_add( */ static void CT_merge_node(ct_node_t * node) { -#if DEBUG assert(node->size == 1 && node->data == NULL); -#endif - ct_node_t * child_node; char * tmp; uint_fast16_t i, end; diff --git a/src/imap/imap.c b/src/imap/imap.c index 7271c9b6..30739c25 100644 --- a/src/imap/imap.c +++ b/src/imap/imap.c @@ -115,10 +115,8 @@ void imap_free(imap_t * imap, imap_free_cb cb) */ int imap_set(imap_t * imap, uint64_t id, void * data) { -#if DEBUG /* insert NULL is not allowed */ assert (data != NULL); -#endif int rc; imap_node_t * nd = imap->nodes + (id % IMAP_NODE_SZ); id /= IMAP_NODE_SZ; @@ -160,10 +158,9 @@ int imap_set(imap_t * imap, uint64_t id, void * data) */ int imap_add(imap_t * imap, uint64_t id, void * data) { -#if DEBUG /* insert NULL is not allowed */ assert (data != NULL); -#endif + imap_node_t * nd = imap->nodes + (id % IMAP_NODE_SZ); id /= IMAP_NODE_SZ; @@ -460,10 +457,8 @@ void imap_union_ref( { if (dest_nd->data != NULL) { -#if DEBUG /* this must be the same object */ assert (imap_nd->data == dest_nd->data); -#endif /* we are sure there is a ref left */ slist_object_decref(imap_nd->data); } @@ -597,10 +592,9 @@ void imap_difference_ref( { if (dest_nd->data != NULL) { -#if DEBUG /* this must be the same object */ assert (imap_nd->data == dest_nd->data); -#endif + /* we are sure to have one ref left */ slist_object_decref(dest_nd->data); dest_nd->data = NULL; @@ -667,10 +661,9 @@ void imap_symmetric_difference_ref( { if (dest_nd->data != NULL) { -#if DEBUG /* this must be the same object */ assert (imap_nd->data == dest_nd->data); -#endif + /* we are sure to have one ref left */ slist_object_decref(dest_nd->data); @@ -980,10 +973,8 @@ static void IMAP_union_ref(imap_node_t * dest, imap_node_t * node) { if (dest_nd->data != NULL) { -#if DEBUG /* this must be the same object */ assert (node_nd->data == dest_nd->data); -#endif /* we are sure there is a ref left */ slist_object_decref(node_nd->data); } @@ -1087,10 +1078,8 @@ static void IMAP_difference_ref( { if (dest_nd->data != NULL) { -#if DEBUG /* this must be the same object */ assert (node_nd->data == dest_nd->data); -#endif /* we are sure to have one ref left */ slist_object_decref(dest_nd->data); dest_nd->data = NULL; @@ -1143,10 +1132,9 @@ static void IMAP_symmetric_difference_ref( { if (dest_nd->data != NULL) { -#if DEBUG /* this must be the same object */ assert (node_nd->data == dest_nd->data); -#endif + /* we are sure to have one ref left */ slist_object_decref(dest_nd->data); diff --git a/src/iso8601/iso8601.c b/src/iso8601/iso8601.c index 3b0217fa..dde56710 100644 --- a/src/iso8601/iso8601.c +++ b/src/iso8601/iso8601.c @@ -671,13 +671,11 @@ static int64_t get_ts( struct tm tm; time_t ts; -#if DEBUG /* must be a valid timezone */ assert (tz >= 0 && tz < TZ_LEN); /* timezone must be 0 (UTC) */ assert (timezone == 0); -#endif memset(&tm, 0, sizeof(struct tm)); diff --git a/src/motd/motd.c b/src/motd/motd.c deleted file mode 100644 index 6b1eb189..00000000 --- a/src/motd/motd.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * motd.c - Message of the day - * - * Note: all quotes are found somewhere on the Internet. - * - * author : Jeroen van der Heijden - * email : jeroen@transceptor.technology - * copyright : 2016, Transceptor Technology - * - * changes - * - initial version, 13-03-2016 - * - */ -#include -#include - -static const char * motd_messages[] = { - "If God had intended Man to program, \n" - "we'd be born with serial I/O ports.", - - "\"On the Internet, no one knows you're using Windows NT\"\n" - "(Submitted by Ramiro Estrugo, restrugo@fateware.com)", - - "Your mail is being routed through Germany ...\n" - "and they're censoring us.", - - "There's got to be more to life than compile-and-go.", - - "One person's error is another person's data.", - - "Nobody said computers were going to be polite.", - - "Little known fact about Middle Earth:\n" - "The Hobbits had a very sophisticated computer network!\n\n" - "It was a Tolkien Ring...", - - "You can do anything, but not everything.\n\n" - "--David Allen", - - "Perfection is achieved, not when there is nothing more to add,\n" - "but when there is nothing left to take away.\n\n" - "--Antoine de Saint-Exupéry", - - "The richest man is not he who has the most,\n" - "but he who needs the least.\n\n" - "--Unknown Author", - - "You miss 100 percent of the shots you never take.\n\n" - "--Wayne Gretzky", - - "Courage is not the absence of fear,\n" - "but rather the judgment that something else is more " - "important than fear.\n\n" - "--Ambrose Redmoon", - - "Everyone is a genius at least once a year.\n" - "The real geniuses simply have their bright ideas closer together.\n\n" - "--Georg Christoph Lichtenberg", - - "Before I got married I had six theories about bringing up children;\n" - "now I have six children and no theories.\n\n" - "--John Wilmot", - - "Those who believe in telekinetics, raise my hand.\n\n" - "--Kurt Vonnegut", - - "We've heard that a million monkeys at a million keyboards could " - "produce the complete works of Shakespeare;\n" - "now, thanks to the Internet, we know that is not true.\n\n" - "--Robert Wilensky", - - "The person who reads too much and uses his brain too little will " - "fall into lazy habits of thinking.\n\n" - "--Albert Einstein", - - "Believe those who are seeking the truth. Doubt those who find it.\n\n" - "--André Gide", - - "It is the mark of an educated mind to be able to entertain a thought " - "without accepting it.\n\n" - "--Aristotle", - - "Pure mathematics is, in its way, the poetry of logical ideas.\n\n" - "--Albert Einstein", - - "Do not worry about your difficulties in Mathematics. " - "I can assure you mine are still greater.\n\n" - "--Albert Einstein", - - "While physics and mathematics may tell us how the universe began,\n" - "they are not much use in predicting human behavior because there " - "are far too many equations to solve.\n" - "I'm no better than anyone else at understanding what makes people " - "tick, particularly women.\n\n" - "--Stephen Hawking", - - "'Obvious' is the most dangerous word in mathematics.\n\n" - "--E. T. Bell", - - "Nobody ever figures out what life is all about, and it doesn't matter.\n" - "Explore the world.\n" - "Nearly everything is really interesting if you go into it deeply enough.\n\n" - "--Richard Feynman", - - "Physics is like sex: sure, it may give some practical results, " - "but that's not why we do it.\n\n" - "--Richard Feynman", - - "You have no responsibility to live up to what other people think " - "you ought to accomplish.\n" - "I have no responsibility to be like they expect me to be.\n" - "It's their mistake, not my failing.\n\n" - "--Richard Feynman", - - "I learned very early the difference between knowing the name of " - "something and knowing something.\n\n" - "--Richard Feynman", - - "Religion is a culture of faith; science is a culture of doubt.\n\n" - "--Richard Feynman", - - "I think it's much more interesting to live not knowing than to have " - "answers which might be wrong.\n\n" - "--Richard Feynman" - -}; - -#define MOTD_SIZE (sizeof (motd_messages) / sizeof (const char *)) - -const char * motd_get_random_msg(void) -{ - return motd_messages[rand() % MOTD_SIZE]; -} diff --git a/src/qpack/qpack.c b/src/qpack/qpack.c index 1e183a51..fb8e1a3a 100644 --- a/src/qpack/qpack.c +++ b/src/qpack/qpack.c @@ -142,9 +142,7 @@ void qp_unpacker_init(qp_unpacker_t * unpacker, unsigned char * pt, size_t len) */ void qp_unpacker_ff_free(qp_unpacker_t * unpacker) { -#if DEBUG assert(unpacker != NULL); -#endif free(unpacker->source); free(unpacker); } @@ -246,9 +244,7 @@ qp_packer_t * qp_packer_new(size_t alloc_size) */ void qp_packer_free(qp_packer_t * packer) { -#if DEBUG assert(packer != NULL); -#endif free(packer->buffer); free(packer); } @@ -587,10 +583,7 @@ int qp_add_null(qp_packer_t * packer) QP_PLAIN_OBJ(QP_NULL) */ int qp_add_type(qp_packer_t * packer, qp_types_t tp) { -#if DEBUG assert(tp >= QP_ARRAY0 && tp <= QP_MAP_CLOSE); -#endif - QP_RESIZE(1) packer->buffer[packer->len++] = tp; return 0; @@ -601,10 +594,7 @@ int qp_add_type(qp_packer_t * packer, qp_types_t tp) */ int qp_fadd_type(qp_fpacker_t * fpacker, qp_types_t tp) { -#if DEBUG assert(tp >= QP_ARRAY0 && tp <= QP_MAP_CLOSE); -#endif - return (fputc(tp, fpacker) == (int) tp) ? 0 : EOF; } diff --git a/src/siri/args/args.c b/src/siri/args/args.c index 040ca265..e668257e 100644 --- a/src/siri/args/args.c +++ b/src/siri/args/args.c @@ -8,7 +8,7 @@ #define DEFAULT_LOG_FILE_MAX_SIZE 50000000 #define DEFAULT_LOG_FILE_NUM_BACKUPS 6 -#if DEBUG +#ifndef NDEBUG #define DEFAULT_LOG_LEVEL "debug" #else #define DEFAULT_LOG_LEVEL "info" diff --git a/src/siri/backup.c b/src/siri/backup.c index 7a843372..2ee9c723 100644 --- a/src/siri/backup.c +++ b/src/siri/backup.c @@ -63,10 +63,8 @@ void siri_backup_destroy(siri_t * siri) */ int siri_backup_enable(siri_t * siri, siridb_t * siridb) { -#if DEBUG assert (~siridb->server->flags & SERVER_FLAG_BACKUP_MODE); assert (~siridb->server->flags & SERVER_FLAG_REINDEXING); -#endif llist_t * llist = (llist_t *) siri->backup->data; @@ -105,9 +103,7 @@ int siri_backup_enable(siri_t * siri, siridb_t * siridb) int siri_backup_disable(siri_t * siri, siridb_t * siridb) { -#if DEBUG assert (siridb->server->flags & SERVER_FLAG_BACKUP_MODE); -#endif int rc = 0; diff --git a/src/siri/db/aggregate.c b/src/siri/db/aggregate.c index bfc55d91..87c3a301 100644 --- a/src/siri/db/aggregate.c +++ b/src/siri/db/aggregate.c @@ -493,10 +493,7 @@ siridb_points_t * siridb_aggregate_run( siridb_aggr_t * aggr, char * err_msg) { -#if DEBUG assert (source->len); -#endif - if (aggr->limit) { return AGGREGATE_limit(source, aggr, err_msg); @@ -1121,13 +1118,7 @@ static siridb_points_t * AGGREGATE_group_by( points->data = point; } } -#if DEBUG - else - { - /* if not smaller it must be equal */ - assert (points->len == max_sz); - } -#endif + /* else { assert (points->len == max_sz); } */ return points; } @@ -1148,9 +1139,7 @@ static int aggr_derivative( siridb_aggr_t * aggr, char * err_msg) { -#if DEBUG assert (points->len); -#endif if (points->tp == TP_STRING) { @@ -1194,9 +1183,7 @@ static int aggr_difference( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif switch (points->tp) { @@ -1252,9 +1239,7 @@ static int aggr_max( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif if (points->tp == TP_STRING) { @@ -1298,9 +1283,7 @@ static int aggr_mean( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif double sum = 0.0; size_t i; @@ -1341,9 +1324,7 @@ static int aggr_median( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif if (points->tp == TP_STRING) { @@ -1385,9 +1366,7 @@ static int aggr_median_high( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif if (points->tp == TP_STRING) { @@ -1420,9 +1399,7 @@ static int aggr_median_low( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif if (points->tp == TP_STRING) { @@ -1455,9 +1432,7 @@ static int aggr_min( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif if (points->tp == TP_STRING) { @@ -1501,9 +1476,7 @@ static int aggr_pvariance( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif switch (points->tp) { @@ -1530,9 +1503,7 @@ static int aggr_sum( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif switch (points->tp) { @@ -1586,9 +1557,7 @@ static int aggr_variance( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif switch (points->tp) { @@ -1616,9 +1585,7 @@ static int aggr_stddev( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg) { -#if DEBUG assert (points->len); -#endif switch (points->tp) { @@ -1646,9 +1613,8 @@ static int aggr_first( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg __attribute__((unused))) { -#if DEBUG assert (points->len); -#endif + siridb_point_t * source = points->data; switch (points->tp) @@ -1682,9 +1648,8 @@ static int aggr_last( siridb_aggr_t * aggr __attribute__((unused)), char * err_msg __attribute__((unused))) { -#if DEBUG assert (points->len); -#endif + siridb_point_t * source = points->data + (points->len - 1); switch (points->tp) diff --git a/src/siri/db/db.c b/src/siri/db/db.c index 5923b142..f7832b92 100644 --- a/src/siri/db/db.c +++ b/src/siri/db/db.c @@ -572,10 +572,6 @@ int siridb_save(siridb_t * siridb) */ void siridb__free(siridb_t * siridb) { -#if DEBUG - log_debug("Free database: '%s'", siridb->dbname); -#endif - /* first we should close the buffer and all other open files */ if (siridb->buffer != NULL) { diff --git a/src/siri/db/ffile.c b/src/siri/db/ffile.c index c366521c..853a3372 100644 --- a/src/siri/db/ffile.c +++ b/src/siri/db/ffile.c @@ -161,9 +161,7 @@ siridb_ffile_result_t siridb_ffile_append( siridb_ffile_t * ffile, sirinet_pkg_t * pkg) { -#if DEBUG assert (ffile->fp != NULL); -#endif uint32_t size = pkg->len + sizeof(sirinet_pkg_t); @@ -211,10 +209,8 @@ int siridb_ffile_check_fn(const char * fn) */ sirinet_pkg_t * siridb_ffile_pop(siridb_ffile_t * ffile) { -#if DEBUG assert (ffile->next_size); assert (ffile->fp != NULL); -#endif if (fseeko( ffile->fp, -(long int) (ffile->next_size + sizeof(uint32_t)), @@ -260,9 +256,7 @@ sirinet_pkg_t * siridb_ffile_pop(siridb_ffile_t * ffile) */ int siridb_ffile_pop_commit(siridb_ffile_t * ffile) { -#if DEBUG assert (ffile->next_size && ffile->fp != NULL); -#endif ffile->size -= ffile->next_size + sizeof(uint32_t); diff --git a/src/siri/db/fifo.c b/src/siri/db/fifo.c index 11f0eed9..cd8b200d 100644 --- a/src/siri/db/fifo.c +++ b/src/siri/db/fifo.c @@ -91,9 +91,7 @@ siridb_fifo_t * siridb_fifo_new(siridb_t * siridb) /* we have at least one fifo in the list */ fifo->out = (siridb_ffile_t *) llist_shift(fifo->fifos); -#if DEBUG assert (fifo->out != NULL); -#endif if (fifo->out->fp == NULL) { @@ -217,9 +215,7 @@ int siridb_fifo_commit(siridb_fifo_t * fifo) } } -#if DEBUG assert (fifo->out != NULL); -#endif return siri_err; } @@ -241,9 +237,7 @@ int siridb_fifo_commit_err(siridb_fifo_t * fifo) */ int siridb_fifo_close(siridb_fifo_t * fifo) { -#if DEBUG assert (fifo->in->fp != NULL); -#endif int rc = 0; /* close the 'in' fifo */ @@ -266,10 +260,7 @@ int siridb_fifo_close(siridb_fifo_t * fifo) */ int siridb_fifo_open(siridb_fifo_t * fifo) { -#if DEBUG assert (fifo->in->fp == NULL); -#endif - /* open fifo 'in' */ siridb_ffile_open(fifo->in, "r+"); diff --git a/src/siri/db/forward.c b/src/siri/db/forward.c index ca719203..03f5ba27 100644 --- a/src/siri/db/forward.c +++ b/src/siri/db/forward.c @@ -93,10 +93,6 @@ void siridb_forward_free(siridb_forward_t * forward) /* free forward */ free(forward); - -#if DEBUG - log_debug("Free forward!, hooray!"); -#endif } /* diff --git a/src/siri/db/group.c b/src/siri/db/group.c index cb3f8cbd..085a074a 100644 --- a/src/siri/db/group.c +++ b/src/siri/db/group.c @@ -359,9 +359,6 @@ void siridb__group_free(siridb_group_t * group) { size_t i; -#if DEBUG - log_debug("Free group: '%s'", group->name); -#endif free(group->name); free(group->source); diff --git a/src/siri/db/groups.c b/src/siri/db/groups.c index 2689746d..f417abc5 100644 --- a/src/siri/db/groups.c +++ b/src/siri/db/groups.c @@ -377,10 +377,6 @@ static int GROUPS_nseries( static void GROUPS_free(siridb_groups_t * groups) { size_t i; - -#if DEBUG - log_debug("Free groups"); -#endif free(groups->fn); if (groups->nseries != NULL) @@ -604,10 +600,8 @@ static void GROUPS_init_groups(siridb_t * siridb) siridb_series_t * series; size_t i; -#if DEBUG /* do not run this function when no groups need initialization */ assert (siridb->groups->ngroups->len); -#endif uv_mutex_lock(&siridb->series_mutex); @@ -628,10 +622,8 @@ static void GROUPS_init_groups(siridb_t * siridb) { group = (siridb_group_t *) slist_pop(groups->ngroups); -#if DEBUG /* we must be sure this group is empty */ assert (group->series->len == 0); -#endif if (~group->flags & GROUP_FLAG_DROPPED) { diff --git a/src/siri/db/initsync.c b/src/siri/db/initsync.c index 6a1f94f8..8392d6ea 100644 --- a/src/siri/db/initsync.c +++ b/src/siri/db/initsync.c @@ -240,11 +240,9 @@ void siridb_initsync_fopen(siridb_initsync_t * initsync, const char * opentype) */ static void INITSYNC_next_series_id(siridb_t * siridb) { -#if DEBUG assert (siridb->replicate != NULL); assert (siridb->replicate->status == REPLICATE_RUNNING || siridb->replicate->status == REPLICATE_STOPPING); -#endif siridb_initsync_t * initsync = siridb->replicate->initsync; @@ -297,9 +295,7 @@ static void INITSYNC_next_series_id(siridb_t * siridb) */ static void INITSYNC_pause(siridb_replicate_t * replicate) { -#if DEBUG assert (replicate->status == REPLICATE_STOPPING); -#endif if (fclose(replicate->initsync->fp)) { log_critical("Error occurred while closing file: '%s'", @@ -317,9 +313,7 @@ static void INITSYNC_pause(siridb_replicate_t * replicate) static void INITSYNC_send(uv_timer_t * timer) { siridb_t * siridb = (siridb_t *) timer->data; -#if DEBUG assert (siridb->replicate->initsync->pkg != NULL); -#endif if (siridb->replicate->status == REPLICATE_STOPPING) { @@ -355,13 +349,12 @@ static void INITSYNC_send(uv_timer_t * timer) static void INITSYNC_work(uv_timer_t * timer) { siridb_t * siridb = (siridb_t *) timer->data; -#if DEBUG + assert (siridb->replicate->status == REPLICATE_RUNNING || siridb->replicate->status == REPLICATE_STOPPING); assert (siridb->replicate->initsync != NULL); assert (siridb->replicate->initsync->fp != NULL); assert (siridb->replicate->initsync->pkg == NULL); -#endif if (siridb->insert_tasks) { @@ -519,9 +512,7 @@ static inline int INITSYNC_fn(siridb_t * siridb, siridb_initsync_t * initsync) */ static int INITSYNC_unlink(siridb_initsync_t * initsync) { -#if DEBUG assert (initsync->fp != NULL); -#endif fclose(initsync->fp); initsync->fp = NULL; diff --git a/src/siri/db/insert.c b/src/siri/db/insert.c index cd1f6b14..2615839a 100644 --- a/src/siri/db/insert.c +++ b/src/siri/db/insert.c @@ -151,10 +151,6 @@ void siridb_insert_free(siridb_insert_t * insert) /* free insert */ free(insert); - -#if DEBUG - log_debug("Free insert!, hooray!"); -#endif } /* @@ -968,9 +964,7 @@ static void INSERT_local_promise_cb( sirinet_pkg_t * pkg, int status) { -#if DEBUG assert (pkg == NULL); -#endif pkg = sirinet_pkg_new( 0, 0, @@ -988,9 +982,7 @@ static void INSERT_local_promise_backend_cb( sirinet_pkg_t * pkg, int status) { -#if DEBUG assert (pkg == NULL); -#endif sirinet_stream_t * client = promise->data; pkg = sirinet_pkg_new( @@ -1231,9 +1223,7 @@ static uint16_t INSERT_get_pool(siridb_t * siridb, qp_obj_t * qp_series_name) * the previous correct pool. (we can do this now * because we known we don't have the series) */ -#if DEBUG assert (siridb->pools->prev_lookup != NULL); -#endif pool = siridb_lookup_sn_raw( siridb->pools->prev_lookup, (const char *) qp_series_name->via.raw, diff --git a/src/siri/db/listener.c b/src/siri/db/listener.c index 4e35ad63..71866539 100644 --- a/src/siri/db/listener.c +++ b/src/siri/db/listener.c @@ -580,9 +580,7 @@ static void enter_alter_stmt(uv_async_t * handle) siridb_user_t * db_user = query->client->origin; SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_ALTER) -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(1024); @@ -643,9 +641,7 @@ static void enter_count_stmt(uv_async_t * handle) siridb_user_t * db_user = query->client->origin; SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_COUNT) -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(256); @@ -709,9 +705,7 @@ static void enter_drop_stmt(uv_async_t * handle) siridb_query_t * query = (siridb_query_t *) handle->data; siridb_user_t * db_user = query->client->origin; -#if DEBUG assert (query->packer == NULL); -#endif SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_DROP) @@ -899,9 +893,7 @@ static void enter_list_stmt(uv_async_t * handle) siridb_user_t * db_user = query->client->origin; SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_LIST) -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(QP_SUGGESTED_SIZE); @@ -1013,9 +1005,7 @@ static void enter_select_stmt(uv_async_t * handle) SIRIPARSER_MASTER_CHECK_ACCESS(db_user, SIRIDB_ACCESS_SELECT) MASTER_CHECK_ACCESSIBLE(siridb) -#if DEBUG assert (query->packer == NULL && query->data == NULL); -#endif query->data = q_select = query_select_new(); @@ -1659,9 +1649,7 @@ static void exit_calc_stmt(uv_async_t * handle) siridb_query_t * query = (siridb_query_t *) handle->data; cleri_node_t * calc_node = query->nodes->node; -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(64); @@ -2233,9 +2221,7 @@ static void exit_create_group(uv_async_t * handle) } else { -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(1024); if (query->packer == NULL) { @@ -2270,11 +2256,9 @@ static void exit_create_user(uv_async_t * handle) cleri_node_t * user_node = query->nodes->node->children->next->node; -#if DEBUG /* both name and packer should be NULL at this point */ assert(user->name == NULL); assert(query->packer == NULL); -#endif MASTER_CHECK_ACCESSIBLE(siridb) @@ -2298,9 +2282,7 @@ static void exit_create_user(uv_async_t * handle) /* success, increment the user reference counter */ siridb_user_incref(user); -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(1024); if (query->packer == NULL) @@ -2704,9 +2686,7 @@ static void exit_grant_user(uv_async_t * handle) return; } -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(1024); @@ -2742,9 +2722,7 @@ static void exit_help_xxx(uv_async_t * handle) if (query->data != NULL) { -#if DEBUG assert (query->packer == NULL); -#endif const char * help = siri_help_get( query->nodes->node->cl_obj->gid, (const char *) query->data, @@ -3258,9 +3236,7 @@ static void exit_revoke_user(uv_async_t * handle) return; } -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(1024); @@ -3572,10 +3548,8 @@ static void exit_set_backup_mode(uv_async_t * handle) siridb_query_t * query = (siridb_query_t *) handle->data; siridb_t * siridb = query->client->siridb; -#if DEBUG assert (query->data != NULL); assert (IS_MASTER); -#endif siridb_server_t * server = ((query_alter_t *) query->data)->via.server; @@ -3798,9 +3772,7 @@ static void exit_set_log_level(uv_async_t * handle) query_alter_t * q_alter = (query_alter_t *) query->data; siridb_t * siridb = query->client->siridb; -#if DEBUG assert (query->data != NULL); -#endif cleri_node_t * node = query->nodes->node->children->next->next->node->children->node; @@ -4127,9 +4099,7 @@ static void exit_show_stmt(uv_async_t * handle) query->nodes->node->children->next->node->children; siridb_props_cb prop_cb; -#if DEBUG assert (query->packer == NULL); -#endif query->packer = sirinet_packer_new(4096); @@ -4167,9 +4137,7 @@ static void exit_show_stmt(uv_async_t * handle) /* get the callback */ prop_cb = siridb_props[children->node->children->node-> cl_obj->gid - KW_OFFSET]; -#if DEBUG assert (prop_cb != NULL); /* all props are implemented */ -#endif prop_cb(siridb, query->packer, 1); if (children->next == NULL) @@ -4618,9 +4586,7 @@ static void async_no_points_aggregate(uv_async_t * handle) */ siridb_series_decref(series); -#if DEBUG assert (q_select->alist->len >= 1); -#endif siridb_aggr_t * aggr = q_select->alist->data[0]; @@ -5934,11 +5900,8 @@ static void on_select_unpack_merged_points( siridb_points_t * points; while ( qp_is_raw(qp_next(unpacker, qp_name)) && -#if DEBUG qp_is_raw_term(qp_name) && -#endif qp_is_array(qp_next(unpacker, NULL))) - { slist_t ** plist = (slist_t **) ct_getaddr( q_select->result, diff --git a/src/siri/db/median.c b/src/siri/db/median.c index 1c2e2f79..bac54eb0 100644 --- a/src/siri/db/median.c +++ b/src/siri/db/median.c @@ -54,9 +54,7 @@ int siridb_median_find_n( siridb_points_t * points, uint64_t n) { -#if DEBUG assert (points->len >= 2); -#endif int rc = 0; uint64_t i, npivot, size_l, size_r; @@ -183,9 +181,7 @@ int siridb_median_real( siridb_points_t * points, double percentage) { -#if DEBUG assert (points->len >= 2); -#endif int rc = 0; uint64_t i, npivot, size_l, size_r, n; bool found_a, found_b; diff --git a/src/siri/db/points.c b/src/siri/db/points.c index c78b9c8b..7edcf5bb 100644 --- a/src/siri/db/points.c +++ b/src/siri/db/points.c @@ -291,9 +291,7 @@ int siridb_points_raw_pack(siridb_points_t * points, qp_packer_t * packer) */ siridb_points_t * siridb_points_merge(slist_t * plist, char * err_msg) { -#if DEBUG assert (plist->len >= 2); -#endif siridb_points_t * points; siridb_points_t * tpts = NULL; size_t n = 0; @@ -340,10 +338,8 @@ siridb_points_t * siridb_points_merge(slist_t * plist, char * err_msg) i++; } -#if DEBUG /* we have at least one series left */ assert (plist->len >= 1); -#endif if (plist->len == 1) { @@ -1410,10 +1406,8 @@ static void POINTS_highest_and_merge(slist_t * plist, siridb_points_t * points) usleep(3000); } } -#if DEBUG /* size should be exactly zero */ assert (n == 0); -#endif } @@ -1458,10 +1452,8 @@ static void POINTS_sort_while_merge(slist_t * plist, siridb_points_t * points) usleep(3000); } } -#if DEBUG /* size should be exactly zero */ assert (n == 0); -#endif } /* @@ -1499,10 +1491,8 @@ static void POINTS_merge_and_sort(slist_t * plist, siridb_points_t * points) } } -#if DEBUG /* size should be exactly zero */ assert (n == 0); -#endif usleep(5000); diff --git a/src/siri/db/pool.c b/src/siri/db/pool.c index af34cc15..d1613782 100644 --- a/src/siri/db/pool.c +++ b/src/siri/db/pool.c @@ -124,10 +124,8 @@ void siridb_pool_add_server(siridb_pool_t * pool, siridb_server_t * server) } else { -#if DEBUG /* we can only have 1 or 2 servers per pool */ assert (pool->len == 2); -#endif /* add the server to the pool, ordered by UUID */ if (siridb_server_cmp(pool->server[0], server) < 0) { @@ -136,9 +134,7 @@ void siridb_pool_add_server(siridb_pool_t * pool, siridb_server_t * server) } else { -#if DEBUG assert (siridb_server_cmp(pool->server[0], server) > 0); -#endif pool->server[1] = pool->server[0]; pool->server[0] = server; diff --git a/src/siri/db/pools.c b/src/siri/db/pools.c index 722b9f2c..81c6c0cc 100644 --- a/src/siri/db/pools.c +++ b/src/siri/db/pools.c @@ -28,11 +28,9 @@ static void POOLS_arrange(siridb_server_t * server, siridb_t * siridb); */ void siridb_pools_init(siridb_t * siridb) { -#if DEBUG assert (siridb->pools == NULL); assert (siridb->servers != NULL && siridb->servers->len > 0); assert (siridb->server != NULL); -#endif siridb->pools = malloc(sizeof(siridb_pools_t)); if (siridb->pools == NULL) @@ -123,9 +121,9 @@ siridb_pool_t * siridb_pools_append( pool->len = 0; siridb_pool_add_server(pool, server); pools->len++; -#if DEBUG + assert (pools->prev_lookup == NULL); -#endif + pools->prev_lookup = pools->lookup; pools->lookup = lookup; } diff --git a/src/siri/db/props.c b/src/siri/db/props.c index dcfbe980..9b01312f 100644 --- a/src/siri/db/props.c +++ b/src/siri/db/props.c @@ -523,10 +523,8 @@ static void prop_time_precision( { SIRIDB_PROP_MAP("time_precision", 14) -#if DEBUG assert (siridb->time->precision >= SIRIDB_TIME_SECONDS && siridb->time->precision <= SIRIDB_TIME_NANOSECONDS); -#endif qp_add_string(packer, siridb_time_short_map[siridb->time->precision]); } diff --git a/src/siri/db/query.c b/src/siri/db/query.c index 1f7f9b10..21fcdeb6 100644 --- a/src/siri/db/query.c +++ b/src/siri/db/query.c @@ -32,10 +32,6 @@ #include #include -#if DEBUG -#include -#endif - #define QUERY_TOO_LONG -1 #define QUERY_MAX_LENGTH 8192 #define QUERY_EXTRA_ALLOC_SIZE 200 @@ -179,10 +175,6 @@ void siridb_query_free(uv_handle_t * handle) /* free handle */ free(handle); - - #if DEBUG - log_debug("Free query!, hooray!"); - #endif } void siridb_send_query_result(uv_async_t * handle) @@ -192,13 +184,9 @@ void siridb_send_query_result(uv_async_t * handle) * clean everything without sending things in case of a client failure */ siridb_query_t * query = (siridb_query_t *) handle->data; -#if DEBUG - if (query->packer == NULL) - { - sprintf(query->err_msg, "CRITICAL: We have nothing to send!"); - return siridb_query_send_error(handle, CPROTO_ERR_QUERY); - } -#endif + + assert (query->packer != NULL); + sirinet_pkg_t * pkg = sirinet_packer2pkg( query->packer, query->pid, @@ -319,13 +307,10 @@ void siridb_query_forward( break; case SIRIDB_QUERY_FWD_SOME_POOLS: -#if DEBUG - assert (((query_select_t *) ((siridb_query_t *) handle->data)->data)->tp == QUERIES_SELECT); assert (((query_select_t *) ((siridb_query_t *) handle->data)->data)->pmap != NULL); -#endif pkg->tp = BPROTO_QUERY_SERVER; { slist_t * borrow_list = imap_slist(((query_select_t *) ( @@ -405,9 +390,7 @@ void siridb_query_timeit_from_unpacker( siridb_query_t * query, qp_unpacker_t * unpacker) { -#if DEBUG assert (query->timeit != NULL); -#endif qp_types_t tp = qp_next(unpacker, NULL); @@ -530,8 +513,6 @@ static void QUERY_send_no_query(uv_async_t * handle) query->packer = sirinet_packer_new(512); qp_add_type(query->packer, QP_MAP1); -#ifndef DEBUG - /* production version returns timestamp now */ siridb_t * siridb = query->client->siridb; qp_add_raw(query->packer, (const unsigned char *) "calc", 4); @@ -547,15 +528,6 @@ static void QUERY_send_no_query(uv_async_t * handle) qp_add_int64(query->packer, (int64_t) (ts * factor)); } -#else - /* development release returns motd */ - const char * msg; - msg = motd_get_random_msg(); - qp_add_raw(query->packer, (const unsigned char *) "motd", 4); - qp_add_string(query->packer, msg); - - -#endif siridb_send_query_result(handle); } diff --git a/src/siri/db/reindex.c b/src/siri/db/reindex.c index 7f74e3a7..7087d59a 100644 --- a/src/siri/db/reindex.c +++ b/src/siri/db/reindex.c @@ -221,9 +221,8 @@ const char * siridb_reindex_progress(siridb_t * siridb) */ void siridb_reindex_close(siridb_reindex_t * reindex) { -#if DEBUG assert (reindex != NULL && reindex->timer != NULL); -#endif + /* we can use uv_timer_stop() even if the timer is not scheduled */ uv_timer_stop(reindex->timer); uv_close((uv_handle_t *) reindex->timer, (uv_close_cb) free); @@ -239,10 +238,7 @@ void siridb_reindex_close(siridb_reindex_t * reindex) */ void siridb_reindex_free(siridb_reindex_t ** reindex) { -#if DEBUG assert ((*reindex)->timer == NULL); - log_debug("Free re-index"); -#endif if ((*reindex)->fp != NULL && fclose((*reindex)->fp)) { ERR_FILE @@ -282,10 +278,8 @@ void siridb_reindex_fopen(siridb_reindex_t * reindex, const char * opentype) */ void siridb_reindex_status_update(siridb_t * siridb) { -#if DEBUG assert (~siridb->server->flags & SERVER_FLAG_REINDEXING); assert (siridb->flags & SIRIDB_FLAG_REINDEXING); -#endif if (siridb_servers_available(siridb)) { siridb->flags &= ~SIRIDB_FLAG_REINDEXING; @@ -313,9 +307,7 @@ void siridb_reindex_start(uv_timer_t * timer) } else { -#if DEBUG assert (siri.optimize->pause); -#endif if (!SIRI_OPTIMZE_IS_PAUSED) { log_debug("Wait for the optimize task to pause"); @@ -338,9 +330,7 @@ void siridb_reindex_start(uv_timer_t * timer) static void REINDEX_send(uv_timer_t * timer) { siridb_t * siridb = (siridb_t *) timer->data; -#if DEBUG assert (siridb->reindex->pkg != NULL); -#endif /* actually 'available' is sufficient since the destination server has * never status 're-indexing' unless one day we support down-scaling. */ @@ -454,11 +444,9 @@ static void REINDEX_work(uv_timer_t * timer) siridb_t * siridb = (siridb_t *) timer->data; siridb_reindex_t * reindex = siridb->reindex; -#if DEBUG assert (SIRI_OPTIMZE_IS_PAUSED); assert (reindex != NULL); assert (siridb->reindex->pkg == NULL); -#endif reindex->series = imap_get(siridb->series_map, *reindex->next_series_id); @@ -477,11 +465,9 @@ static void REINDEX_work(uv_timer_t * timer) * lock is not needed since we are sure the optimize task is * not running */ -#if DEBUG assert (siridb_lookup_sn( siridb->pools->prev_lookup, reindex->series->name) == siridb->server->pool); -#endif siridb_points_t * points = siridb_series_get_points( reindex->series, NULL, @@ -661,9 +647,7 @@ static inline int REINDEX_fn(siridb_t * siridb, siridb_reindex_t * reindex) */ static int REINDEX_unlink(siridb_reindex_t * reindex) { -#if DEBUG assert (reindex->fp != NULL); -#endif fclose(reindex->fp); reindex->fp = NULL; diff --git a/src/siri/db/replicate.c b/src/siri/db/replicate.c index 9f0cda26..f2daa976 100644 --- a/src/siri/db/replicate.c +++ b/src/siri/db/replicate.c @@ -44,9 +44,7 @@ static void REPLICATE_on_repl_finished_response( */ int siridb_replicate_init(siridb_t * siridb, siridb_initsync_t * initsync) { -#if DEBUG assert (siri.loop != NULL); -#endif siridb->replicate = (siridb_replicate_t *) malloc(sizeof(siridb_replicate_t)); @@ -83,11 +81,9 @@ int siridb_replicate_init(siridb_t * siridb, siridb_initsync_t * initsync) */ void siridb_replicate_close(siridb_replicate_t * replicate) { -#if DEBUG assert (replicate != NULL && replicate->timer != NULL && replicate->status != REPLICATE_CLOSED); -#endif /* we can use uv_timer_stop() even if the timer is not scheduled */ uv_timer_stop(replicate->timer); uv_close((uv_handle_t *) replicate->timer, (uv_close_cb) free); @@ -103,10 +99,7 @@ void siridb_replicate_close(siridb_replicate_t * replicate) */ void siridb_replicate_free(siridb_replicate_t ** replicate) { -#if DEBUG - log_debug("Free replicate"); assert ((*replicate)->status == REPLICATE_CLOSED); -#endif if ((*replicate)->initsync != NULL) { siridb_initsync_free(&(*replicate)->initsync); @@ -136,9 +129,7 @@ int siridb_replicate_pkg(siridb_t * siridb, sirinet_pkg_t * pkg) */ void siridb_replicate_start(siridb_replicate_t * replicate) { -#if DEBUG assert (siridb_replicate_is_idle(replicate)); -#endif replicate->status = REPLICATE_RUNNING; if (replicate->initsync == NULL) { @@ -161,9 +152,7 @@ void siridb_replicate_start(siridb_replicate_t * replicate) */ void siridb_replicate_pause(siridb_replicate_t * replicate) { -#if DEBUG assert (replicate->status != REPLICATE_CLOSED); -#endif replicate->status = (replicate->status == REPLICATE_IDLE) ? REPLICATE_PAUSED : REPLICATE_STOPPING; } @@ -175,11 +164,9 @@ void siridb_replicate_pause(siridb_replicate_t * replicate) */ void siridb_replicate_continue(siridb_replicate_t * replicate) { -#if DEBUG /* make sure the fifo buffer is open */ assert (siridb_fifo_is_open(((siridb_t *) replicate->timer->data)->fifo)); assert (replicate->status != REPLICATE_CLOSED); -#endif replicate->status = (replicate->status == REPLICATE_STOPPING) ? REPLICATE_RUNNING : REPLICATE_IDLE; @@ -212,7 +199,6 @@ static void REPLICATE_work(uv_timer_t * handle) siridb_t * siridb = (siridb_t *) handle->data; sirinet_pkg_t * pkg; -#if DEBUG assert (siridb->fifo != NULL); assert (siridb->replicate != NULL); assert (siridb->replica != NULL); @@ -221,7 +207,6 @@ static void REPLICATE_work(uv_timer_t * handle) assert (siridb->replicate->status != REPLICATE_CLOSED); assert (siridb->replicate->initsync == NULL); assert (siridb_fifo_is_open(siridb->fifo)); -#endif if ( siridb->replicate->status == REPLICATE_RUNNING && siridb_fifo_has_data(siridb->fifo) && @@ -333,11 +318,9 @@ static void REPLICATE_on_repl_response( { siridb_t * siridb = (siridb_t *) promise->data; -#if DEBUG /* open promises must be closed before siridb->replicate is destroyed */ assert (siridb->replicate != NULL); assert (siridb->fifo != NULL); -#endif switch ((sirinet_promise_status_t) status) { diff --git a/src/siri/db/series.c b/src/siri/db/series.c index 563539a1..12e9598b 100644 --- a/src/siri/db/series.c +++ b/src/siri/db/series.c @@ -127,10 +127,8 @@ int siridb_series_add_point( uint64_t * ts, qp_via_t * val) { -#if DEBUG assert (!siri_err); assert (series->buffer != NULL); -#endif int rc = 0; series->length++; @@ -340,13 +338,6 @@ void siridb__series_free(siridb_series_t *__restrict series) siridb_shard_t * shard; uint_fast32_t i; -#if DEBUG - if (siri.status == SIRI_STATUS_RUNNING || 0) - { - log_debug("Free series: '%s'", series->name); - } -#endif - /* mark shards with dropped series flag */ for (i = 0; i < series->idx_len; i++) { @@ -379,10 +370,8 @@ int siridb_series_load(siridb_t * siridb) { imap_t * dropped; -#if DEBUG /* we must have a server because we need to know the pool id */ assert (siridb->server != NULL); -#endif log_info("Loading series"); dropped = imap_new(); @@ -509,9 +498,7 @@ void siridb_series_drop_prepare(siridb_t * siridb, siridb_series_t * series) */ int siridb_series_drop_commit(siridb_t * siridb, siridb_series_t * series) { -#if DEBUG assert (series->flags & SIRIDB_SERIES_IS_DROPPED); -#endif int rc = 0; @@ -813,10 +800,8 @@ siridb_points_t * siridb_series_get_first( (*required_shard)++; -#if DEBUG /* if not in the buffer, then if must be in a shard */ assert (series->idx_len); -#endif idx_t * first = series->idx; @@ -835,11 +820,9 @@ siridb_points_t * siridb_series_get_first( &start, series->flags & SIRIDB_SERIES_HAS_OVERLAP); -#if DEBUG /* we must have at least one point, more points are possible when * having multiple points at the same time-stamp. */ assert (points->len); -#endif while (points->len > 1) { @@ -879,11 +862,8 @@ siridb_points_t * siridb_series_get_last( (*required_shard)++; - -#if DEBUG /* if not in the buffer, then if must be in a shard */ assert (series->idx_len); -#endif /* if not in the buffer, then if must be in a shard */ @@ -912,11 +892,9 @@ siridb_points_t * siridb_series_get_last( NULL, series->flags & SIRIDB_SERIES_HAS_OVERLAP); -#if DEBUG /* we must have at least one point, more points are possible when * having multiple points at the same time-stamp. */ assert (points->len); -#endif while (points->len > 1) { @@ -1079,13 +1057,11 @@ int siridb_series_optimize_shard( size += idx->len; end++; -#if DEBUG /* * we have at least 2 references to the shard so we never * reach 0 here. (this ref + optimize ref) */ assert(shard->replacing->ref >= 2); -#endif siridb_shard_decref(shard->replacing); } else if (idx->shard == shard && end) @@ -1170,9 +1146,7 @@ int siridb_series_optimize_shard( } while (idx->shard == shard); -#if DEBUG assert (idx->shard == shard->replacing); -#endif idx->shard = shard; idx->start_ts = points->data[pstart].ts; @@ -1235,13 +1209,11 @@ int siridb_series_optimize_shard( series->idx = idx; } } -#if DEBUG else { /* start must be equal to end if not smaller */ assert (i == end); } -#endif if (series->flags & SIRIDB_SERIES_HAS_OVERLAP) { @@ -1326,9 +1298,8 @@ static void SERIES_update_overlap(siridb_series_t *__restrict series) { uint_fast32_t i; -#if DEBUG assert (series->flags & SIRIDB_SERIES_HAS_OVERLAP); -#endif + for (i = 1; i < series->idx_len; i++) { if (series->idx[i - 1].end_ts > series->idx[i].start_ts) @@ -1397,11 +1368,9 @@ static siridb_series_t * SERIES_new( series->flags |= SIRIDB_SERIES_IS_SERVER_ONE; } -#if DEBUG /* make sure these two are exactly the same */ assert (siridb_series_server_id(series) == siridb_series_server_id_by_name(series->name)); -#endif if (siridb->time->precision == SIRIDB_TIME_SECONDS) { diff --git a/src/siri/db/server.c b/src/siri/db/server.c index 778c150b..cfe7c011 100644 --- a/src/siri/db/server.c +++ b/src/siri/db/server.c @@ -135,11 +135,9 @@ int siridb_server_send_pkg( void * data, int flags) { -#if DEBUG assert (server->client != NULL); assert (server->promises != NULL); assert (cb != NULL); -#endif int rc; uint8_t n = 0; sirinet_promise_t * promise = @@ -309,16 +307,12 @@ siridb_server_t * siridb_server_register( void siridb_server_send_flags(siridb_server_t * server) { -#if DEBUG assert (server->client != NULL); assert (siridb_server_is_online(server)); -#endif sirinet_stream_t * client = server->client; -#if DEBUG assert (client->siridb != NULL); -#endif int16_t n = client->siridb->server->flags; QP_PACK_INT16(buffer, n) @@ -402,10 +396,8 @@ int siridb_server_update_address( */ void siridb_server_connect(siridb_t * siridb, siridb_server_t * server) { -#if DEBUG /* server->socket must be NULL at this point */ assert (server->client == NULL); -#endif server->client = sirinet_stream_new(STREAM_TCP_SERVER, &SERVER_on_data); @@ -880,17 +872,13 @@ siridb_server_t * siridb_server_from_node( int siridb_server_drop(siridb_t * siridb, siridb_server_t * server) { int rc = 0; -#if DEBUG assert (siridb->server != server); -#endif siridb_pool_t * pool = siridb->pools->pool + server->pool; switch (server->id) { case 0: -#if DEBUG assert (pool->len == 2); -#endif pool->server[0] = pool->server[1]; pool->server[0]->id = 0; /* FALLTHRU */ @@ -933,12 +921,11 @@ int siridb_server_drop(siridb_t * siridb, siridb_server_t * server) siridb_server_decref(server); rc = siridb_servers_save(siridb); } -#if DEBUG else { + /* can never be reached */ assert (0); } -#endif return rc; } @@ -950,9 +937,6 @@ int siridb_server_drop(siridb_t * siridb, siridb_server_t * server) */ void siridb__server_free(siridb_server_t * server) { -#if DEBUG - log_debug("Free server: '%s'", server->name); -#endif /* we MUST first free the promises because each promise has a reference to * this server and the promise callback might depend on this. */ @@ -1230,9 +1214,7 @@ static int SERVER_update_name(siridb_server_t * server) char * tmp; int fmt_as_ipv6 = 0; /* false */ -#if DEBUG assert (server->port > 0); -#endif /* append 'string' length for server->port */ for (; i; i /= 10, len++); @@ -1246,9 +1228,7 @@ static int SERVER_update_name(siridb_server_t * server) /* append 'address' length */ len += strlen(server->address); -#if DEBUG assert (len > 0); -#endif /* allocate enough space */ tmp = (char *) realloc(server->name, len); diff --git a/src/siri/db/servers.c b/src/siri/db/servers.c index 9c6aea60..a083efbc 100644 --- a/src/siri/db/servers.c +++ b/src/siri/db/servers.c @@ -236,11 +236,9 @@ int siridb_servers_register(siridb_t * siridb, siridb_server_t * server) if (siridb->server->pool == server->pool) { /* this is a replica for 'this' pool */ -#if DEBUG assert (siridb->replicate == NULL); assert (siridb->fifo == NULL); assert (siridb->replica == NULL); -#endif siridb->replica = server; siridb->fifo = siridb_fifo_new(siridb); diff --git a/src/siri/db/shard.c b/src/siri/db/shard.c index cef76232..8b5d4905 100644 --- a/src/siri/db/shard.c +++ b/src/siri/db/shard.c @@ -1540,10 +1540,6 @@ void siridb__shard_free(siridb_shard_t * shard) /* this will close the file, even when other references exist */ siri_fp_decref(shard->fp); -#if DEBUG - log_debug("Free shard id: %" PRIu64, shard->id); -#endif - free(shard->fn); free(shard); } diff --git a/src/siri/db/user.c b/src/siri/db/user.c index 72111c8a..5a0f1ed8 100644 --- a/src/siri/db/user.c +++ b/src/siri/db/user.c @@ -238,9 +238,6 @@ int siridb_user_cexpr_cb(siridb_user_t * user, cexpr_condition_t * cond) */ void siridb__user_free(siridb_user_t * user) { -#if DEBUG - log_debug("Free user: '%s'", user->name); -#endif free(user->name); free(user->password); free(user); diff --git a/src/siri/heartbeat.c b/src/siri/heartbeat.c index e398f499..9e8f23f6 100644 --- a/src/siri/heartbeat.c +++ b/src/siri/heartbeat.c @@ -59,9 +59,7 @@ static void HEARTBEAT_cb(uv_timer_t * handle __attribute__((unused))) llist_node_t * siridb_node; llist_node_t * server_node; -#if DEBUG log_debug("Start heart-beat task"); -#endif siridb_node = siri.siridb_list->first; diff --git a/src/siri/help/help.c b/src/siri/help/help.c index 068fb35a..4c6a1ad7 100644 --- a/src/siri/help/help.c +++ b/src/siri/help/help.c @@ -122,10 +122,6 @@ void siri_help_free(void) { uint_fast16_t i; -#if DEBUG - log_debug("Free help"); -#endif - for (i = 0; i < HELP_COUNT; i ++) { free(siri_help_content[i]); diff --git a/src/siri/net/bserver.c b/src/siri/net/bserver.c index 46a80022..85a527dd 100644 --- a/src/siri/net/bserver.c +++ b/src/siri/net/bserver.c @@ -75,9 +75,7 @@ static uv_tcp_t backend_server; int sirinet_bserver_init(siri_t * siri) { -#if DEBUG assert (loop == NULL); -#endif int rc; int ip_v6 = 0; /* false */ @@ -518,9 +516,7 @@ static void on_insert( siridb_t * siridb = client->siridb; if ((flags & INSERT_FLAG_POOL) && siridb->replica != NULL) { -#if DEBUG assert (siridb->fifo != NULL); -#endif sirinet_pkg_t * repl_pkg; if (siridb->replicate->initsync == NULL) diff --git a/src/siri/net/clserver.c b/src/siri/net/clserver.c index 65ba365f..bd0bcbc9 100644 --- a/src/siri/net/clserver.c +++ b/src/siri/net/clserver.c @@ -106,9 +106,7 @@ static void CLSERVER_on_register_server_response( int sirinet_clserver_init(siri_t * siri) { -#if DEBUG assert (loop == NULL && siri->loop != NULL); -#endif int rc; int ip_v6 = 0; /* false */ diff --git a/src/siri/net/pkg.c b/src/siri/net/pkg.c index dc6b2f94..5a78260b 100644 --- a/src/siri/net/pkg.c +++ b/src/siri/net/pkg.c @@ -67,9 +67,7 @@ sirinet_pkg_t * sirinet_pkg_new( */ qp_packer_t * sirinet_packer_new(size_t alloc_size) { -#if DEBUG assert (alloc_size >= sizeof(sirinet_pkg_t)); -#endif qp_packer_t * packer = qp_packer_new(alloc_size); if (packer == NULL) @@ -119,9 +117,7 @@ sirinet_pkg_t * sirinet_pkg_err( uint8_t tp, const char * msg) { -#if DEBUG assert (msg != NULL); -#endif sirinet_pkg_t * pkg; qp_packer_t * packer = sirinet_packer_new(len + 20 + sizeof(sirinet_pkg_t)); diff --git a/src/siri/net/stream.c b/src/siri/net/stream.c index ae1c644a..32c94695 100644 --- a/src/siri/net/stream.c +++ b/src/siri/net/stream.c @@ -250,10 +250,6 @@ void sirinet__stream_free(uv_stream_t * uvclient) { sirinet_stream_t * client = uvclient->data; -#if DEBUG - log_debug("Free socket client type: %d", client->tp); -#endif - switch (client->tp) { case STREAM_PIPE_CLIENT: diff --git a/src/siri/optimize.c b/src/siri/optimize.c index 4a22b644..c55adf19 100644 --- a/src/siri/optimize.c +++ b/src/siri/optimize.c @@ -98,9 +98,7 @@ void siri_optimize_pause(void) */ void siri_optimize_continue(void) { -#if DEBUG assert (optimize.pause); -#endif if (!--optimize.pause && optimize.status == SIRI_OPTIMIZE_PAUSED_MAIN) { log_debug("Optimize task was paused by the main thread, continue..."); @@ -118,9 +116,7 @@ int siri_optimize_wait(void) /* its possible that another database is paused, but we wait anyway */ if (optimize.pause) { -#if DEBUG assert (optimize.status == SIRI_OPTIMIZE_RUNNING); -#endif optimize.status = SIRI_OPTIMIZE_PAUSED; /* close open index file in case this is required */ @@ -185,9 +181,8 @@ int siri_optimize_wait(void) */ int siri_optimize_create_idx(const char * fn) { -#if DEBUG assert (optimize.idx_fn == NULL && strlen(fn) > 3); -#endif + /* copy file name */ optimize.idx_fn = strdup(fn); if (optimize.idx_fn == NULL) @@ -308,9 +303,7 @@ static void OPTIMIZE_work(uv_work_t * work __attribute__((unused))) size_t j; siridb = (siridb_t *) slsiridb->data[i]; -#if DEBUG log_debug("Start optimizing database '%s'", siridb->dbname); -#endif uv_mutex_lock(&siridb->shards_mutex); @@ -383,9 +376,7 @@ static void OPTIMIZE_work(uv_work_t * work __attribute__((unused))) { break; } -#if DEBUG log_debug("Finished optimizing database '%s'", siridb->dbname); -#endif } OPTIMIZE_cleanup(slsiridb); } diff --git a/src/siri/siri.c b/src/siri/siri.c index 8db933fb..683e08f3 100644 --- a/src/siri/siri.c +++ b/src/siri/siri.c @@ -103,7 +103,7 @@ void siri_setup_logger(void) char lname[255]; size_t len = strlen(siri.args->log_level); -#ifndef DEBUG +#ifdef NDEBUG /* force colors while debugging... */ if (siri.args->log_colorized) #endif @@ -515,7 +515,7 @@ static void SIRI_walk_close_handlers( /* we do not expect any timer object since they should all be closed * (or at least closing) at this point. */ -#if DEBUG +#ifndef NDEBUG LOGC( "Found a non closing Timer, all timers should " "be stopped at this point."); #endif @@ -524,7 +524,7 @@ static void SIRI_walk_close_handlers( break; case UV_ASYNC: -#if DEBUG +#ifndef NDEBUG LOGC( "An async task is only expected to be found in case " "not all tasks were closed within the timeout limit, " "or when a critical signal error is raised."); @@ -534,7 +534,7 @@ static void SIRI_walk_close_handlers( default: -#if DEBUG +#ifndef NDEBUG LOGC("Oh oh, we might need to implement type %d", handle->type); assert(0); #endif